package com.design.strategy;

import com.design.strategy.pay.PayStrategy;
import com.design.strategy.pay.CommonPay;

/**
 * 订单类
 * @Author:         cong zhi
 * @CreateDate:     2021/4/4 15:20
 * @UpdateUser:     cong zhi
 * @UpdateDate:     2021/4/4 15:20
 * @UpdateRemark:   修改内容
 * @Version:        1.0
 */
public class Order {


    private String uid;

    private String orderId;

    private double amount;

    public Order(String uid, String orderId, double amount) {
        this.uid = uid;
        this.orderId = orderId;
        this.amount = amount;
    }


    public MsgResult pay(){
        return pay(null);
    }

    public MsgResult pay(String payKey) {
        CommonPay commonPay = PayStrategy.get(payKey);

        System.out.println("欢迎使用" + commonPay.getName());
        System.out.println("本次交易金额为：" + amount + ",开始扣款");
        return commonPay.pay(uid, amount);
    }
}
